package wms2010.gui.forms.ageClass;

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import wms2010.controller.controller.IDisciplineController;
import wms2010.model.controller.model.Discipline;

@Component
public class DisciplineComboboxModel extends AbstractListModel implements ComboBoxModel {
	private List<DisciplineViewModel> disciplineList = new ArrayList<DisciplineViewModel>();
	private Object selectedItem;
	
 	public void setDisciplineList(List<Discipline> disciplineList) {
 		for(Discipline discipline : disciplineList) {
 			this.disciplineList.add(new DisciplineViewModel(discipline));
 		}
	}

 	public void removeDiscipline(DisciplineViewModel discipline) {
 		int index = this.disciplineList.indexOf(discipline);
 		this.disciplineList.remove(discipline);
 		this.fireIntervalRemoved(discipline, index, index);
 	}
	
	public Object getSelectedItem() {
		return this.selectedItem;
	}

	public void setSelectedItem(Object anItem) {
		this.selectedItem = anItem;
	}


	public Object getElementAt(int index) {
		return this.disciplineList.get(index);
	}

	public int getSize() {
		return this.disciplineList.size();
	}
}
